import request from "@/utils/request";
import { rootsUrl } from "../utils";
import { getToken } from "@/utils/auth";

/**
 * 门票--个人预约
 * @param {Object} data
 */
export const personalAppoint = data => {
  console.log(data);
  return request({
    url: `${rootsUrl[2]}/cbticket/order/grSave.shtml`,
    method: "post",
    data
  });
};

/**
 * 获取个人预约列表--门票
 */
export const getPersonalAppoint = pageIndex => {
  let token = getToken();
  return request({
    url: `${rootsUrl[2]}/cbticket/orderList/grOrderList.shtml`,
    method: "get",
    params: {
      token,
      pageSize: 10,
      pageIndex
    }
  });
};

/**
 * 取消预约--个人预约门票
 */
export const cancelAppoint = data => {
  let token = getToken();
  return request({
    url: `${rootsUrl[2]}/cbticket/order/cancelOrder.shtml`,
    method: "post",
    data: {
      orderId: data.orderId,
      sysOrderId: data.sysOrderId,
      ticketId: data.ticketId,
      token
    }
  });
};

/**
 * 获取团队预约列表
 */
export const getGroupAppointList = pageIndex => {
  let token = getToken();
  return request({
    url: `${rootsUrl[2]}/cbticket/order/tdOrderList.shtml`,
    method: "get",
    params: {
      token,
      pageSize: 10,
      pageIndex
    }
  });
};

/**
 * 获取我的活动预约列表
 * @param {Number} userId 用户ID
 */
export const getMyActList = (userId, pageIndex, pageSize) => {
  let token = getToken();
  return request({
    url: `${rootsUrl[1]}/cbeducate/lecture/getLecturePersonList.shtml`,
    method: "get",
    params: {
      token,
      mid: userId,
      pageIndex,
      pageSize: 10
    }
  });
};
